package com.vichat.common.rudp;

import com.vichat.common.util.DateUtil;

import java.net.SocketAddress;
import java.util.ArrayList;

public class RudpTransData {

    public byte[] transId;
    public boolean outgoing;
    public ArrayList<RudpBlockData> blockList;
    public int lifeTime;
    public int interval;
    public long createTime;
    public long retransTime;
    public int blockNum = 0;
    public boolean indicated = false;
    public SocketAddress remoteAddr;
    public int fd;

    public int dataLength = 0;
    public int receiveNum = 0;

    private String strTransId = null;

    public RudpTransData(byte[] intransId, int inblockNum, int inlifeTime) {
        transId = intransId;
        blockNum = inblockNum;
        createTime = DateUtil.getCalendarCurrentTimeInMillis();
        lifeTime = inlifeTime;
        blockList = new ArrayList<RudpBlockData>(blockNum);
    }

    public String getStringTrans() {
        if (strTransId == null) {
            strTransId = ProtocolUtil.transIdStr(this.transId);
        }
        return strTransId;
    }

}
